package com.idol;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author Supreme_Sir
 * @version 1.0
 * @className PermissionInterceptor
 * @description 用户权限拦截器
 * @date 2020/11/1 19:36
 **/
public class PermissionInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Boolean permission = (Boolean) request.getSession().getAttribute("permission");
        if (null != permission && permission) {
            return true;
        }
        request.getRequestDispatcher("/WEB-INF/jsp/login.jsp").forward(request, response);
        return false;
    }
}
